package com.txy.domain.strategy.service.rule.tree.factory;

import com.txy.domain.strategy.model.vo.RuleLogicCheckTypeVO;
import com.txy.domain.strategy.model.vo.RuleTreeVO;
import com.txy.domain.strategy.service.rule.tree.ILogicTreeNode;
import com.txy.domain.strategy.service.rule.tree.factory.engine.DecisionTreeEngine;
import com.txy.domain.strategy.service.rule.tree.factory.engine.IDecisionTreeEngine;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class DefaultTreeFactory {
    private final Map<String, ILogicTreeNode> logicTreeGroup;

    public DefaultTreeFactory(Map<String, ILogicTreeNode> logicTreeGroup) {
        this.logicTreeGroup = logicTreeGroup;
    }

    public IDecisionTreeEngine openLoginRuleTree(RuleTreeVO ruleTreeVO) {
        return new DecisionTreeEngine(logicTreeGroup, ruleTreeVO);
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class AwardResClass {
        private Integer awardId;
        private String awardValue;
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class DecisionEngineRes {
        RuleLogicCheckTypeVO ruleLogicCheckTypeVO;
        AwardResClass awardResClass;
    }
}
